package trunk.src.Table;

/**
 * The Class Table.
 */
public class Table {

	/** The id. */
	String id;

	/** The value. */
	Integer value;

	/** The tail. */
	Table tail;

	/**
	 * Instantiates a new table.
	 * 
	 * @param i
	 *            the i
	 * @param v
	 *            the v
	 * @param t
	 *            the t
	 */
	public Table(String i, Integer v, Table t) {
		id = i;
		value = v;
		tail = t;
	}

	/**
	 * Lookup the key in this table.
	 * 
	 * @param key
	 *            the key
	 * @return the integer, null if the key is not found
	 */
	public Integer lookup(String key) {
		if (this.id.equals(key)) {
			return this.value;
		} else if (this.tail != null) {
			return this.tail.lookup(key);
		}
		return null;
	}
}
